import time

from pom.basepage.basepage import BasePage
from lib.share import *

class TRelease(BasePage):
    loc_page_title = (xpath,"//*[@class='page-title ng-scope']")
    loc_complate_info_value = "//table/tbody/*[index1]/*[5]/a/i"
    loc_release_all_student = (xpath,"//tbody/tr")

    loc_release_student_nextpage = (xpath,"//*[@class='input-group-btn']/button[@ng-click='nextPage()']")

    loc_delete_value = "//tbody/*[index1]//*[@class='fa fa-undo']"
    loc_delete_submit = (xpath,"//*[@class='bootstrap-dialog-footer-buttons']/*[2]")
    loc_delete_cancel = (xpath,"//*[@class='bootstrap-dialog-footer-buttons']/*[1]")

    loc_delect_lose = (xpath,"//*[@class='bootstrap-dialog-footer-buttons']/button")
    loc_delete_lose_txt = (css,'.bootstrap-dialog-message')

    loc_next_page = (xpath,"//*[@ng-click='nextPage()']")

    loc_after = (css,'#createTimeAfter')
    loc_before = (css,'#createTimeBefore')
    loc_search = (xpath,"//*[@id='createTimeBefore']/../button")

    loc_released_homework = (xpath,'//*[@ng-repeat="task in taskTable"]')

    loc_students = (css,'[ng-repeat]')
    loc_check_txt_student = (xpath,"//thead/tr/*[1]")

    loc_release_time_value = "//tbody/*[index1]//*[2]"

    def release_student_count(self):
        release_student_count = 0
        while True:
            release_student = len(self.locates(self.loc_release_all_student))
            release_student_count += release_student

            self.driver.implicitly_wait(1)
            try:
                self.locate(self.loc_release_student_nextpage)
                self.click(self.loc_release_student_nextpage)
            except:
                break
            self.driver.implicitly_wait(1)

        return release_student_count



